﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@{
    ViewBag.Title = "Databases";
}

<h2>@ViewBag.Title</h2>
<h3>@ViewBag.Message</h3>

@if (ViewBag.Error != null)
{
    <div><b>@ViewBag.Error</b></div>
    <div>@ViewBag.ErrorDetail</div>
    <div></div>
}

<div>
    <big><b>Add new database shard:</b></big>
    <form action="/Databases/Add" method="post" enctype="multipart/form-data">
        <table>
            <tr>
                <td height ="40" width="200">
                    Name:
                </td>
                <td>
                    <input id="dbname" name="dbName" type="text" />
                </td>
            </tr>
            <tr>
                <td height="40">
                    Identifier (optional):
                </td>
                <td>
                    <input id="dbIdentifier" name="dbIdentifier" type="text" />
                </td>
            </tr>
            <tr>
                <td height="40">
                    URL (htttp://host.domain:port):
                </td>
                <td>
                    <input id="dbURL" name="dbURL" type="text" />
                </td>
            </tr>
            <tr>
                <td height="40">
                    Shard (database):
                </td>
                <td>
                    <input id="dbShard" name="dbShard" type="text" />
                </td>
            </tr>
            <tr>
                <td align="right" colspan="2">
                    <input type="submit" value="Add" style="width:100px;"  />
                </td>
            </tr>
        </table>
    </form>
</div>
<hr>
<div>
    <big><b>List of known shards:</b></big>
    <table>
        <tr>
            <td width="100"><b><i>Name</i></b></td>
            <td width="100"><b><i>Identifier</i></b></td>
            <td width="250"><b><i>URL</i></b></td>
            <td width="150"><b><i>Database name</i></b></td>
        </tr>


        @if (ViewBag.shards != null)
        {
            foreach (DDBS_Server.Models.Shard shard in (List<DDBS_Server.Models.Shard>)ViewBag.shards)
            {
                <tr>
                    <td>@shard.Name</td>
                    <td>
                        @if (shard.Identifier != null)
                        {@shard.Identifier}
                    </td>
                    <td>@shard.URL</td>
                    <td>@shard.DB</td>
                </tr>
            }
        }
        
    </table>
    
</div>